﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Member_Master.Master" AutoEventWireup="true" CodeBehind="M_MainMarket.aspx.cs" Inherits="WebApplication.M_MainMarket" %>
<%@ Register TagPrefix="uc1" TagName="usermeg" Src="~/UserControl/M_UserMessageControl.ascx" %>
<%@ Register TagPrefix="uc1" TagName="maintab" Src="~/UserControl/M_MainTabControl.ascx" %>
<%--<%@ Register TagPrefix="uc1" TagName="usermeg" Src="~/UserControl/UserMessageControl.ascx" %>
<%@ Register TagPrefix="uc1" TagName="maintab" Src="~/UserControl/MainTabControl.ascx" %>--%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="Media/Css/master2.css" rel="stylesheet" media="all"/>
<link href="Media/Css/PeterCss.css" rel="Stylesheet" media="all" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#menu1_ul1").find("li").each(function (i) {
            $(this).click(function () { $(this).children("span").toggleClass("span" + (i + 1)); });
        })
        $("#menu1_ul2").find("li").each(function (i) {
            $(this).click(function () { $(this).children("span").toggleClass("span" + (i + 1)); });
        })
    })
</script>
 <script type="text/javascript">
     $(document).ready(function () {
         //market 
         $("#menu1_ul1").find("li").each(function (i) {
             $(this).click(function () { $(this).children("span").toggleClass("span" + (i + 1)); });
         });

         $("#menu1_ul2").find(".li1").children("span").addClass("span1");

         $("#menu1_ul2").find("li").each(function (i) {
             $(this).click(function () {
                 $("#menu1_ul2").find("li").children("span").removeAttr("class");
                 $(this).children("span").addClass("span" + (i + 1));
                 display_area($(this).children("span").attr("title"));
             });
         });

         $("#ContentPlaceHolder2_lblMessages").html('');

         ///父项的父项勾选事件
         $("#ContentPlaceHolder2_CheckBox_AllArae").click(function () {
             if ($(this).attr("checked") == true) {
                 $.each([1, 2, 3, 4, 5, 6, 7, 8], function (i) {
                     $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").attr("checked", 'true'); //全选
                     $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", 'true');
                 });
             }
             else {
                 $.each([1, 2, 3, 4, 5, 6, 7, 8], function (i) {
                     $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").attr("checked", ''); //全不选
                     $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", '');
                 });
             }
         });

         ///父项勾选事件  
         $.each([1, 2, 3, 4, 5, 6, 7, 8], function (i) {
             $("#ContentPlaceHolder2_CheckBox" + i).click(function () {
                 if ($(this).attr("checked") == true) {
                     $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").attr("checked", 'true'); //全选
                 }
                 else {
                     $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").attr("checked", ''); //全不选
                 }
             });
         });

         /// 子项勾选事件
         $("input").not("#ContentPlaceHolder2_CheckBox_AllArae").click(function () {
             SubItemCheck(); //根据子项选中情况 绑定父项（所以的子项全选的时候 父项选中，子项任何一个未选父项设为未选）！
         });

         //根据子项选中情况 绑定父项（所以的子项全选的时候 父项选中）！
         SubItemCheck();
     });


     //根据子项选中情况 绑定父项（所以的子项全选的时候 父项选中，子项任何一个未选父项设为未选）！
     function SubItemCheck() {
         $.each([1, 2, 3, 4, 5, 6, 7, 8], function (i) {
             var SubItem = $("#ContentPlaceHolder2_CheckBoxList" + i).find("input");
             var allChildChecked = true;
             $.each(SubItem, function (j) {
                 if (SubItem.eq(j).attr("checked") != true) {
                     allChildChecked = false;
                     return false;
                 }
                 else {
                     return true;
                 }
             });

             if (allChildChecked == true) {
                 $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", 'true');
             }
             else {
                 $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", '');
             }
         });



         var allParentChecked = true;
         $.each([1, 2, 3, 4, 5, 6, 7, 8], function (i) {
             if ($("#ContentPlaceHolder2_CheckBox" + i).attr("checked") != true) {
                 if ($("#ContentPlaceHolder2_CheckBox" + i).html() == null) {
                     return true;
                 }
                 else {
                     allParentChecked = false;
                     return false;
                 }
             }
             else {
                 return true;
             }
         });

         if (allParentChecked == true) {
             $("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked", 'true');
         }
         else {
             $("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked", '');
         }

     }

     ///以 子区域 显示 
     function display_area(i) {
         $("#div_allCountry").find(".country_for_area").css("display", "none");
         $("#div" + i).css("display", "block");
     }


     $(document).ready(function () {
         checkIsHas();
         $("#menu1_ul2").find("li").each(function (i) {
             $(this).click(function () {
                 $("#menu1_ul2").find("li").children("span").removeClass();
                 $(this).children("span").addClass("span" + (i + 1));
                 $(".country_for_area").hide();
                 $("#div" + i).show();
             });
         });

         $("#ContentPlaceHolder2_lblMessages").html('');
         $(".labelTb").find("input[type='checkbox']").click(function () {
             checkIsHas();
         });

     });





     //选择全子项
     function selectAll(num) {
         var val = $("#ContentPlaceHolder2_CheckBox" + num).attr("checked");
         $("#ContentPlaceHolder2_CheckBoxList" + num).find("input").attr("checked", val);
         checkIsHas()
     }

     function selectAllWorld() {

         if ($("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked")) {
             $("#div_allCountry").find("input").attr("checked", 'true');
             $("#menu1_ul2").find(".selected").css("visibility", "visible");

         }
         else {
             $("#div_allCountry").find("input").attr("checked", '');
             $("#menu1_ul2").find(".selected").css("visibility", "hidden");

         }

     }
     function checkIsHas() {
         $("#menu1_ul2").find(".selected").css("visibility", "hidden");

         for (i = 1; i < 8; i++) {
             var has = false; //判断是否有，并且是否全部被选
             var all = false;
             $("#ContentPlaceHolder2_CheckBoxList" + i).find("input").each(function () {
                 if ($(this).attr("checked")) {
                     has = true;
                     //$("#menu1_ul2").find(".li" + i).find(".selected").css("visibility", "visible");
                     if (has && all)
                         return false;

                 } else {
                     all = true;
                     if (has && all)
                         return false;
                     //$("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "");
                     // $("#div_allCountry").find("input").attr("checked", '');
                 }

             })

             if (has) {
                 $("#menu1_ul2").find(".li" + i).find(".selected").css("visibility", "visible");
             }

             if (all) {
                 $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "");
                 $("#ContentPlaceHolder2_CheckBox_AllArae").attr("checked", '');
             } else {
                 $("#ContentPlaceHolder2_CheckBox" + i).attr("checked", "true");
             }

         }

     }

     function GetInfo() {
         GetChangeVal();
        if ($("#ContentPlaceHolder2_lkBtnSave").hasClass("aspNetDisabled").toString() != "true") {
            $("#ContentPlaceHolder2_lblMeg").html("Data being processed, please wait...");
        } else {
            $("#ContentPlaceHolder2_lblMeg").html("You currently do not have permission to operate...");
        }
        //var t = setTimeout(timeOut, 10000);
    }
    function timeOut() {
        $("#ContentPlaceHolder2_lblMeg").html("");
    }

    function Quit() {
        
        $("#ContentPlaceHolder2_lblMeg").html("Cancel your operation...");
    }

    function GetChangeVal() {
        var addVal = "";
        var proVal = "";
        var delVal = "";
        var hiddenStr = $("#ContentPlaceHolder2_HiddenField_val").val();
        var hiddenVal = hiddenStr.substring(0, hiddenStr.length - 1).split(",");

        for (i = 0; i < 8; i++) {
            $("#ContentPlaceHolder2_CheckBoxList" + i).find("input:checked").each(function (m, n) {
                var has = true;
                for (j = 0; j < hiddenVal.length; j++) {
                    if (n.value == hiddenVal[j]) {
                        has = false;
                        break;
                    }
                }
                if (has) {
                    addVal += n.value + ",";
                }
                else {
                    proVal += n.value + ",";
                }

                var msg = $(this).next("label").text();                
            });
        }
        proVal = proVal.substring(0, proVal.length - 1).split(",");

        for (i = 0; i < hiddenVal.length; i++) {
            var has = true;
            for (j = 0; j < proVal.length; j++) {
                if (hiddenVal[i] == proVal[j]) {
                    has = false;
                    break;
                }
            }
            if (has) {
                delVal += hiddenVal[i] + ",";
            }
        }
        
        $("#ContentPlaceHolder2_HiddenFiled_add").attr("value", addVal);
        $("#ContentPlaceHolder2_HiddenFiled_del").attr("value", delVal);
    }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true" runat="Server" ID="ScriptManager1" />

<div class="content-title">
        <h1>
            Membership Info</h1>
    </div>
<input type="hidden" value="t7" id="pageName" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<uc1:usermeg ID="usermeg" runat="server" ></uc1:usermeg>
<div class="partWrap">
<uc1:maintab ID="maintab"  runat="server"/>		
    <div class="clear20"></div>
	
		<div class="productWrap">
	<div class="productTitle">	
	</div>
	<div class="CheckWrap">
	<div class="clear10"></div>
	<table cellpadding="0" cellspacing="0" class="labelTb" width="100%">
      <tr>
         <td colspan="3">
          <input id="ContentPlaceHolder2_CheckBox_AllArae" type="checkbox" name="ctl00$ContentPlaceHolder2$CheckBox_AllArae" /><label for="ContentPlaceHolder2_CheckBox_AllArae"><strong>World Wide 世界各地</strong></label>
         </td>
       </tr>
    </table>
    <div class="clear10"></div>
	<ul class="menu1_ul menu2" id="menu1_ul2">
            <li class="li1">
                <div class="selected">
                    √</div>
                <span title="4">Africa</span></li>
            <li class="li2">
                <div class="selected">
                    √</div>
                <span title="1">Asia</span></li>

            <li class="li3">
                <div class="selected">
                    √</div>
                <span title="3">Australia</span></li>
            <li class="li4">
                <div class="selected">
                    √</div>

                <span title="7">Europe</span></li>
            <li class="li5">
                <div class="selected">
                    √</div>
                <span title="2">Middle East<</span></li>
            <li class="li6">
                <div class="selected">

                    √</div>
                <span title="5">North America</span></li>
            <li class="li7">
                <div class="selected">
                    √</div>
                <span title="6">South America</span></li>
        </ul>

	<div class="clear20"></div>
    <div id="div8">
        <div id="div0" style="display: block;" class="country_for_area">
            <p>
                <asp:CheckBox onclick="selectAll(1)" ID="CheckBox1" runat="server" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList1" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--亚洲--%>
        <div id="div1" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox2" onchange="selectAll('2')" runat="server" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList2" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--澳洲--%>
        <div id="div2" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox3" onchange="selectAll('3')" runat="server" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList3" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--欧洲--%>
        <div id="div3" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox4" onchange="selectAll('4')" runat="server" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList4" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--中东--%>
        <div id="div4" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox5" runat="server" onchange="selectAll('5')" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList5" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--北美--%>
        <div id="div5" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox6" onchange="selectAll('6')" runat="server" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList6" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
        <%--南美--%>
        <div id="div6" style="display: none;" class="country_for_area">
            <p>
                <asp:CheckBox ID="CheckBox7" runat="server"  onchange="selectAll('7')" Text="<strong>All</strong>" /><br />
            </p>
            <asp:CheckBoxList ID="CheckBoxList7" runat="server" CssClass="labelTb" RepeatColumns="3"
                RepeatDirection="Horizontal" Width="100%" CellPadding="0" CellSpacing="0">
            </asp:CheckBoxList>
        </div>
    </div>
    <asp:HiddenField runat="server" ID="HiddenField_val" />
    <asp:HiddenField runat="server" ID="HiddenFiled_add" />
    <asp:HiddenField runat="server" ID="HiddenFiled_del" />
    
</div><!-- CheckWrap end-->
</div><!-- productWrap end-->
<div class="clear20"></div> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>  
        <table width="200" border="0" cellspacing="0" cellpadding="0">
	        <tr>
	        <td width="80">
		        <ul class="uibtn">
    	        <li><span><asp:LinkButton ID="LbtnSave" runat="server" OnClick="LbtnSave_Click" OnClientClick="return GetInfo()">Save</asp:LinkButton></span></li>
	        </ul>
	        </td>
	        <td>
		        <ul class="uibtn">
    	        <li><span><asp:LinkButton ID="LbtnQuit" runat="server" OnClick="LbtnQuit_Click" OnClientClick="return Quit()">Quit</asp:LinkButton></span></li>
	            </ul>
	        </td>				
	        </tr>
        </table>		
    <div class="clear20"></div> 
    <asp:Label ID="lblMeg" CssClass="clsWarningMeg" runat="server"></asp:Label>  
    </div><!-- partWrap end-->	
   </ContentTemplate>
  </asp:UpdatePanel>
</asp:Content>
